clear
cap log close

cd "D:\Dropbox\Work\Research\CreditCardABSRewrite\Draft\ReplicationFiles\Tab_10"

local today = "`c(current_date)'"
log using "Table_10_Log.log", text append

import delimited "Data_Table_10.csv"

* generate indicators for subperiods
generate pre=1 if year<2007
generate cri=1 if year>2006 & year<2010
generate post=1 if year>2009 & year<2020

* Table 10

*****************
* A Tranche
* All
regress riskprem_a risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year, vce(cluster year)
outreg2 using Tab10_A, stats(coef tstat) noaster adjr2 nocons title("A Tranche") ctitle("All") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word replace

* 2000-2006
regress riskprem_a risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if pre==1, vce(cluster year)
outreg2 using Tab10_A, stats(coef tstat) noaster adjr2 nocons title("A Tranche") ctitle("2000-2006") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word 

* 2007-2009
regress riskprem_a risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if cri==1, vce(cluster year)
outreg2 using Tab10_A, stats(coef tstat) noaster adjr2 nocons title("A Tranche") ctitle("2007-2009") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2010-2020
regress riskprem_a risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if post==1, vce(cluster year)
outreg2 using Tab10_A, stats(coef tstat) noaster adjr2 nocons title("A Tranche") ctitle("2010-2020") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word


*******************
* B Tranche
* All
regress riskprem_b risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year, vce(cluster year)
outreg2 using Tab10_B, stats(coef tstat) noaster adjr2 nocons title("B Tranche") ctitle("All") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word replace

* 2000-2006
regress riskprem_b risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if pre==1, vce(cluster year)
outreg2 using Tab10_B, stats(coef tstat) noaster adjr2 nocons title("B Tranche") ctitle("2000-2006") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2007-2009
regress riskprem_b risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if cri==1, vce(cluster year)
outreg2 using Tab10_B, stats(coef tstat) noaster adjr2 nocons title("B Tranche") ctitle("2007-2009") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2010-2020
regress riskprem_b risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if post==1, vce(cluster year)
outreg2 using Tab10_B, stats(coef tstat) noaster adjr2 nocons title("B Tranche") ctitle("2010-2020") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word


*******************
* C Tranche
* All
regress riskprem_c risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year, vce(cluster year)
outreg2 using Tab10_C, stats(coef tstat) noaster adjr2 nocons title("C Tranche") ctitle("All") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word replace

* 2000-2006
regress riskprem_c risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if pre==1, vce(cluster year)
outreg2 using Tab10_C, stats(coef tstat) noaster  adjr2 nocons title("C Tranche") ctitle("2000-2006") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2007-2009
regress riskprem_c risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if cri==1, vce(cluster year)
outreg2 using Tab10_C, stats(coef tstat) noaster adjr2 nocons title("C Tranche") ctitle("2007-2009") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

* 2010-2020
regress riskprem_c risk capital cds c.risk#c.intensity c.capital#c.intensity c.cds#c.intensity i.year if post==1, vce(cluster year)
outreg2 using Tab10_C, stats(coef tstat) noaster  adjr2 nocons title("C Tranche") ctitle("2010-2020") drop(i.year riskprem*) bdec(4) bfmt(f) tdec(2) tfmt(f) rdec(3) rfmt(f) word

log close